/**
 * 选择采购单据 - 新建关联用
 * 
 * @author PSI
 * @copyright 2015 - present
 * @license GPL v3
 */
PCL.define("PSI.SLN0001.Vat.SelectPurchaseForm", {
  extend: "PSI.AFX.Form.EditForm",

  config: {
    companyId: "",
    companyName: "",
  },

  /**
   * 初始化组件
   * 
   * @override
   */
  initComponent() {
    const me = this;

    const entity = me.getEntity();

    const buttons = [];

    let btn = {
      text: "新建关联",
      ...PSI.Const.BTN_STYLE,
      iconCls: "PSI-button-ok",
      handler() {
        me._onOK();
      },
      scope: me
    };
    buttons.push(btn);

    btn = {
      text: "取消",
      ...PSI.Const.BTN_STYLE,
      handler() {
        me.close();
      },
      scope: me
    };
    buttons.push(btn);

    PCL.apply(me, {
      header: {
        title: me.formatTitle(PSI.Const.PROD_NAME),
        height: 40
      },
      maximized: true,
      layout: "border",
      listeners: {
        show: {
          fn: me._onWndShow,
          scope: me
        },
        close: {
          fn: me._onWndClose,
          scope: me
        }
      },
      items: [{
        region: "north",
        border: 0,
        height: 100,
        layout: {
          type: "table",
          columns: 6,
        },
        xtype: "form",
        defaultType: 'textfield',
        fieldDefaults: {
          labelWidth: 70,
          labelAlign: "right",
          labelSeparator: "",
          msgTarget: 'side',
          width: 400,
          margin: "5"
        },
        items: [{
          fieldLabel: "组织机构",
          colspan: 2,
          value: me.getCompanyName(),
          readOnly: true,
        }, {
          fieldLabel: "发票号",
          value: entity.get("ref"),
          colspan: 2,
          readOnly: true,
        }, {
          fieldLabel: "供应商",
          value: entity.get("supplierName"),
          colspan: 2,
          readOnly: true,
        }, {
          id: me.buildId(me, "editQueryRef"),
          colspan: 2,
          fieldLabel: "单据号",
        }, {
          xtype: "container",
          colspan: 2,
          items: [{
            xtype: "button",
            text: "查询",
            cls: "PSI-Query-btn1",
            width: 100,
            height: 26,
            margin: "5 0 0 10",
            handler: me._onQuery,
            scope: me
          }, {
            xtype: "button",
            text: "清空查询条件",
            cls: "PSI-Query-btn2",
            width: 100,
            height: 26,
            margin: "5, 0, 0, 10",
            handler: me._onClearQuery,
            scope: me
          }]
        }, {
          xtype: "container",
          colspan: 2
        }, {
          xtype: "displayfield",
          fieldLabel: "操作说明",
          colspan: 6,
          value: me.toFieldNoteText("在下面的列表中，选择一个采购业务单据，建立与当前发票的关联"),
          width: 1000,
        }]
      }, {
        region: "center",
        border: 0,
        layout: "border",
        items: [
          {
            id: me.buildId(me, "tabPanelMain"),
            region: "center",
            layout: "fit",
            bodyStyle: { borderWidth: 0 },
            border: 0,
            xtype: "tabpanel",
            items: [{
              id: "tabPW",
              title: "采购入库单",
              border: 0,
              layout: "border",
              margin: 5,
              items: [
                {
                  region: "center",
                  layout: "fit",
                  border: 0,
                  tbar: me.getPWGridPagination(),
                  items: me.getPWMainGrid(),
                }, {
                  region: "south",
                  height: "40%",
                  layout: "fit",
                  border: 0,
                  items: me.getPWDetailGrid(),
                }
              ]
            }, {
              id: "tabPR",
              title: "采购退货出库单",
              border: 0,
              layout: "border",
              margin: 5,
              items: [
                {
                  region: "center",
                  layout: "fit",
                  border: 0,
                  tbar: me.getPRGridPagination(),
                  items: me.getPRMainGrid(),
                }, {
                  region: "south",
                  height: "40%",
                  layout: "fit",
                  border: 0,
                  items: me.getPRDetailGrid(),
                }
              ]
            }, {
              id: "tabFee",
              title: "采购费用",
              border: 0,
              layout: "border",
              margin: 5,
              items: []
            },],
          }
        ]
      }],
      buttons,
    });

    me.callParent(arguments);

    me.editQueryRef = PCL.getCmp(me.buildId(me, "editQueryRef"));
    me.tabPanelMain = PCL.getCmp(me.buildId(me, "tabPanelMain"));

    me._onQuery.apply(me);
  },

  /**
   * @private
   */
  _onOK() {
    const me = this;

    const selectTabId = me.tabPanelMain.getActiveTab().getId();

    let billId = "";
    let billType = 0;
    let ref = "";
    let billName = "";

    if (selectTabId == "tabPW") {
      // 采购入库单
      billType = 1;
      billName = "采购入库单";

      const item = me.getPWMainGrid().getSelectionModel().getSelection();
      if (item == null || item.length != 1) {
        me.showInfo("请选择采购入库单");
        return;
      }
      const bill = item[0];
      billId = bill.get("id");
      ref = bill.get("ref");
    } else if (selectTabId == "tabPR") {
      // 采购退货出库单
      billType = 2;
      billName = "采购退货出库单";

      const item = me.getPRMainGrid().getSelectionModel().getSelection();
      if (item == null || item.length != 1) {
        me.showInfo("请选择采购退货出库单");
        return;
      }
      const bill = item[0];
      billId = bill.get("id");
      ref = bill.get("ref");
    } else {
      // 莫名的bug
      me.showInfo("请选择采购单据");
      return;
    }

    const vatRef = me.getEntity().get("ref");
    const info = `请确认是否建立：<br/>
                  增值税发票记录(发票号:<span style='color:red'>${vatRef}</span>) <br/> 
                  ${billName}(单号:<span style='color:red'>${ref}</span>) 的关联?`;

    const funcConfirm = () => {
      const el = PCL.getBody();
      el.mask("正在处理中...");
      const r = {
        url: me.URL("SLN0001/Vat/addRelation"),
        params: {
          vatId: me.getEntity().get("id"),
          billId,
          billType,
        },
        callback(options, success, response) {
          el.unmask();

          if (success) {
            const data = me.decodeJSON(response.responseText);
            if (data.success) {
              const parentForm = me.getParentForm();
              if (parentForm && parentForm.refreshDetailGrid) {
                parentForm.refreshDetailGrid.apply(parentForm, [data.id]);
              }
              me.tip("成功完成操作", true);
              me.close();
            } else {
              me.showInfo(data.msg);
            }
          } else {
            me.showInfo("网络错误");
          }
        }
      };
      me.ajax(r);
    };

    me.confirm(info, funcConfirm);
  },

  /**
   * @private
   */
  _onWndClose() {
    const me = this;

    // AFX
    PCL.get(window).un('beforeunload', me.__onWindowBeforeUnload);

    const parentForm = me.getParentForm();
    if (parentForm) {
      parentForm._keyMapMain.enable();
    }
  },

  /**
   * @private
   */
  _onWndShow() {
    const me = this;

    // AFX
    PCL.get(window).on('beforeunload', me.__onWindowBeforeUnload);

    const parentForm = me.getParentForm();
    if (parentForm) {
      parentForm._keyMapMain.disable();
    }
  },

  /**
   * @private
   */
  getPWMainGrid() {
    const me = this;
    if (me._pwMainGrid) {
      return me._pwMainGrid;
    }

    const modelName = me.buildModelName(me, "PWBill");
    PCL.define(modelName, {
      extend: "PCL.data.Model",
      fields: ["id", "ref", "bizDate", "supplierName",
        "warehouseName", "inputUserName", "bizUserName",
        "billStatus", "billStatusCode", "amount", "dateCreated",
        "paymentType", "billMemo", "tax", "moneyWithTax"]
    });
    const store = PCL.create("PCL.data.Store", {
      autoLoad: false,
      model: modelName,
      data: [],
      pageSize: 20,
      proxy: {
        type: "ajax",
        actionMethods: {
          read: "POST"
        },
        url: me.URL("SLN0001/Vat/pwbillList"),
        reader: {
          root: 'dataList',
          totalProperty: 'totalCount'
        }
      }
    });
    store.on("beforeload", () => {
      store.proxy.extraParams = me.getQueryParamForPW();
    });

    me._pwMainGrid = PCL.create("PCL.grid.Panel", {
      cls: "PSI-FC",
      viewConfig: {
        enableTextSelection: true
      },
      border: 1,
      columnLines: true,
      columns: {
        defaults: {
          menuDisabled: true,
          sortable: false
        },
        items: [{
          xtype: "rownumberer",
          text: "#",
          width: 50
        }, {
          header: "状态",
          dataIndex: "billStatus",
          width: 110,
          renderer(value) {
            if (value == "待入库(在途)") {
              return "<span style='color:red'>" + value
                + "</span>";
            } else if (value == "部分退货") {
              return "<span style='color:blue'>" + value
                + "</span>";
            } else if (value == "全部退货") {
              return "<span style='color:green'>" + value
                + "</span>";
            } else {
              return value;
            }
          }
        }, {
          header: "入库单号",
          dataIndex: "ref",
          width: 120
        }, {
          header: "业务日期",
          dataIndex: "bizDate",
          width: 90,
          align: "center"
        }, {
          header: "供应商",
          dataIndex: "supplierName",
          width: 300
        }, {
          header: "采购金额",
          dataIndex: "amount",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "税金",
          dataIndex: "tax",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "价税合计",
          dataIndex: "moneyWithTax",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "付款方式",
          dataIndex: "paymentType",
          width: 100,
          renderer(value) {
            if (value == 0) {
              return "记应付账款";
            } else if (value == 1) {
              return "现金付款";
            } else if (value == 2) {
              return "用预付款支付";
            } else {
              return "";
            }
          }
        }, {
          header: "入库仓库",
          dataIndex: "warehouseName"
        }, {
          header: "业务员",
          dataIndex: "bizUserName"
        }, {
          header: "制单人",
          dataIndex: "inputUserName"
        }, {
          header: "制单时间",
          dataIndex: "dateCreated",
          width: 150
        }, {
          header: "备注",
          dataIndex: "billMemo",
          width: 150
        }]
      },
      store,
      listeners: {
        select: {
          fn: me._onPWMainGridSelect,
          scope: me
        },
      }
    });

    return me._pwMainGrid;
  },

  /**
   * @private
   */
  getPWDetailGrid() {
    const me = this;
    if (me._pwDetailGrid) {
      return me._pwDetailGrid;
    }

    const modelName = me.buildModelName(me, "PWBillDetail");
    PCL.define(modelName, {
      extend: "PCL.data.Model",
      fields: ["id", "goodsCode", "goodsName", "goodsSpec",
        "unitName", "goodsCount", "goodsMoney",
        "goodsPrice", "memo", "taxRate", "tax",
        "moneyWithTax", "goodsPriceWithTax", "rejGoodsCount", "realGoodsCount"]
    });
    const store = PCL.create("PCL.data.Store", {
      autoLoad: false,
      model: modelName,
      data: []
    });

    me._pwDetailGrid = PCL.create("PCL.grid.Panel", {
      cls: "PSI-HL",
      viewConfig: {
        enableTextSelection: true
      },
      border: 1,
      columnLines: true,
      columns: {
        defaults: {
          menuDisabled: true,
          sortable: false
        },
        items: [PCL.create("PCL.grid.RowNumberer", {
          text: "#",
          width: 40
        }), {
          header: "物料编码",
          dataIndex: "goodsCode"
        }, {
          header: "品名/规格型号",
          dataIndex: "goodsName",
          width: 330,
          renderer(value, metaData, record) {
            return record.get("goodsName") + " " + record.get("goodsSpec");
          }
        }, {
          header: "入库数量",
          width: 80,
          dataIndex: "goodsCount",
          align: "right"
        }, {
          header: "退货数量",
          width: 80,
          dataIndex: "rejGoodsCount",
          align: "right"
        }, {
          header: "实际入库数量",
          width: 100,
          dataIndex: "realGoodsCount",
          align: "right"
        }, {
          header: "单位",
          dataIndex: "unitName",
          width: 50,
          align: "center"
        }, {
          header: "采购单价",
          dataIndex: "goodsPrice",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "采购金额",
          dataIndex: "goodsMoney",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "税率(%)",
          dataIndex: "taxRate",
          align: "right",
          xtype: "numbercolumn",
          format: "0",
          width: 60
        }, {
          header: "税金",
          dataIndex: "tax",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "价税合计",
          dataIndex: "moneyWithTax",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "含税价",
          dataIndex: "goodsPriceWithTax",
          align: "right",
          xtype: "numbercolumn",
          width: 90,
        }, {
          header: "备注",
          dataIndex: "memo",
          width: 200
        }]
      },
      store,
    });

    return me._pwDetailGrid;
  },

  /**
   * @private
   */
  getPWGridPagination() {
    const me = this;
    const store = me.getPWMainGrid().getStore();
    const result = [{
      id: me.buildId(me, "pagingToobarPWGrid"),
      xtype: "pagingtoolbar",
      border: 0,
      store
    }, "-", {
      xtype: "displayfield",
      fieldStyle: "font-size:13px",
      value: "每页显示"
    }, {
      id: "comboCountPerPagePWGrid",
      xtype: "combobox",
      editable: false,
      width: 60,
      store: PCL.create("PCL.data.ArrayStore", {
        fields: ["text"],
        data: [["20"], ["50"], ["100"], ["300"],
        ["1000"]]
      }),
      value: 20,
      listeners: {
        change: {
          fn() {
            store.pageSize = PCL.getCmp("comboCountPerPagePWGRid").getValue();
            store.currentPage = 1;
            PCL.getCmp(me.buildId(me, "pagingToobarPWGrid")).doRefresh();
          },
          scope: me
        }
      }
    }, {
      xtype: "displayfield",
      fieldStyle: "font-size:13px",
      value: "张采购入库单"
    }];

    return result;
  },

  /**
   * @private
   */
  getPRMainGrid() {
    const me = this;
    if (me._prMainGrid) {
      return me._prMainGrid;
    }

    const modelName = me.buildModelName(me, "PRBill");
    PCL.define(modelName, {
      extend: "PCL.data.Model",
      fields: ["id", "ref", "bizDT", "warehouseName",
        "supplierName", "inputUserName", "bizUserName",
        "billStatus", "rejMoney", "dateCreated",
        "receivingType", "billMemo", "tax", "rejMoneyWithTax", "pwRef"]
    });
    const store = PCL.create("PCL.data.Store", {
      autoLoad: false,
      model: modelName,
      data: [],
      pageSize: 20,
      proxy: {
        type: "ajax",
        actionMethods: {
          read: "POST"
        },
        url: me.URL("SLN0001/Vat/prbillList"),
        reader: {
          root: 'dataList',
          totalProperty: 'totalCount'
        }
      }
    });
    store.on("beforeload", () => {
      store.proxy.extraParams = me.getQueryParamForPR();
    });

    me._prMainGrid = PCL.create("PCL.grid.Panel", {
      cls: "PSI-FC",
      viewConfig: {
        enableTextSelection: true
      },
      border: 1,
      columnLines: true,
      columns: [{
        xtype: "rownumberer",
        text: "#",
        width: 40
      }, {
        header: "状态",
        dataIndex: "billStatus",
        menuDisabled: true,
        sortable: false,
        width: 60,
        renderer(value) {
          return value == "待出库"
            ? `<span style='color:red'>${value}</span>`
            : value;
        }
      }, {
        header: "退货出库单号",
        dataIndex: "ref",
        width: 120,
        menuDisabled: true,
        sortable: false
      }, {
        header: "采购入库单号",
        dataIndex: "pwRef",
        width: 120,
        menuDisabled: true,
        sortable: false,
        renderer(value, md, record) {
          return `<a href='${PSI.Const.BASE_URL}SLN0001/Bill/viewIndex?fid=2039&refType=${encodeURIComponent("采购入库")}&ref=${encodeURIComponent(value)}' 
                    target='_blank'>${value}
                  </a>`;
        }
      }, {
        header: "业务日期",
        dataIndex: "bizDT",
        menuDisabled: true,
        sortable: false,
        width: 90,
        align: "center"
      }, {
        header: "供应商",
        dataIndex: "supplierName",
        menuDisabled: true,
        sortable: false,
        width: 300
      }, {
        header: "收款方式",
        dataIndex: "receivingType",
        menuDisabled: true,
        sortable: false,
        width: 90,
        renderer(value) {
          if (value == 0) {
            return "记应收账款";
          } else if (value == 1) {
            return "现金收款";
          } else {
            return "";
          }
        }
      }, {
        header: "出库仓库",
        dataIndex: "warehouseName",
        menuDisabled: true,
        sortable: false,
        width: 150
      }, {
        header: "退货金额(不含税)",
        dataIndex: "rejMoney",
        menuDisabled: true,
        sortable: false,
        align: "right",
        xtype: "numbercolumn",
        width: 120
      }, {
        header: "税金(红字)",
        dataIndex: "tax",
        menuDisabled: true,
        sortable: false,
        align: "right",
        xtype: "numbercolumn",
        width: 90
      }, {
        header: "退货金额(含税)",
        dataIndex: "rejMoneyWithTax",
        menuDisabled: true,
        sortable: false,
        align: "right",
        xtype: "numbercolumn",
        width: 120
      }, {
        header: "业务员",
        dataIndex: "bizUserName",
        menuDisabled: true,
        sortable: false
      }, {
        header: "制单人",
        dataIndex: "inputUserName",
        menuDisabled: true,
        sortable: false
      }, {
        header: "制单时间",
        dataIndex: "dateCreated",
        width: 150,
        menuDisabled: true,
        sortable: false
      }, {
        header: "备注",
        dataIndex: "billMemo",
        width: 300,
        menuDisabled: true,
        sortable: false
      }],
      listeners: {
        select: {
          fn: me._onPRMainGridSelect,
          scope: me
        },
      },
      store,
    });

    return me._prMainGrid;
  },

  /**
   * @private
   */
  getPRDetailGrid() {
    const me = this;
    if (me._prDetailGrid) {
      return me._prDetailGrid;
    }

    const modelName = me.buildModelName(me, "PRBillDetail");
    PCL.define(modelName, {
      extend: "PCL.data.Model",
      fields: ["id", "goodsCode", "goodsName", "goodsSpec",
        "unitName", "rejCount", "rejPrice", "rejMoney",
        "memo", "tax", "taxRate", "rejPriceWithTax", "rejMoneyWithTax"]
    });
    const store = PCL.create("PCL.data.Store", {
      autoLoad: false,
      model: modelName,
      data: []
    });

    me._prDetailGrid = PCL.create("PCL.grid.Panel", {
      cls: "PSI-HL",
      viewConfig: {
        enableTextSelection: true
      },
      columnLines: true,
      columns: [PCL.create("PCL.grid.RowNumberer", {
        text: "#",
        width: 40
      }), {
        header: "物料编码",
        dataIndex: "goodsCode",
        menuDisabled: true,
        sortable: false
      }, {
        header: "品名/规格型号",
        dataIndex: "goodsName",
        menuDisabled: true,
        sortable: false,
        width: 330,
        renderer(value, metaData, record) {
          return record.get("goodsName") + " " + record.get("goodsSpec");
        }
      }, {
        header: "退货数量",
        dataIndex: "rejCount",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 80
      }, {
        header: "单位",
        dataIndex: "unitName",
        menuDisabled: true,
        sortable: false,
        width: 50,
        align: "center"
      }, {
        header: "退货单价(不含税)",
        dataIndex: "rejPrice",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 120,
        xtype: "numbercolumn"
      }, {
        header: "退货金额(不含税)",
        dataIndex: "rejMoney",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 120,
        xtype: "numbercolumn"
      }, {
        header: "税率(%)",
        dataIndex: "taxRate",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 60,
        xtype: "numbercolumn",
        format: "#"
      }, {
        header: "税金(红字)",
        dataIndex: "tax",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 100,
        xtype: "numbercolumn"
      }, {
        header: "退货单价(含税)",
        dataIndex: "rejPriceWithTax",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 120,
        xtype: "numbercolumn"
      }, {
        header: "退货金额(含税)",
        dataIndex: "rejMoneyWithTax",
        menuDisabled: true,
        sortable: false,
        align: "right",
        width: 120,
        xtype: "numbercolumn"
      }, {
        header: "备注",
        dataIndex: "memo",
        menuDisabled: true,
        sortable: false,
        width: 300
      }],
      store,
    });

    return me._prDetailGrid;
  },

  /**
   * @private
   */
  getPRGridPagination() {
    const me = this;
    const store = me.getPRMainGrid().getStore();
    const result = [{
      id: me.buildId(me, "pagingToobarPRGrid"),
      xtype: "pagingtoolbar",
      border: 0,
      store: store
    }, "-", {
      xtype: "displayfield",
      fieldStyle: "font-size:13px",
      value: "每页显示"
    }, {
      id: me.buildId(me, "comboCountPerPagePRGrid"),
      xtype: "combobox",
      editable: false,
      width: 60,
      store: PCL.create("PCL.data.ArrayStore", {
        fields: ["text"],
        data: [["20"], ["50"], ["100"],
        ["300"], ["1000"]]
      }),
      value: 20,
      listeners: {
        change: {
          fn() {
            store.pageSize = PCL.getCmp(me.buildId(me, "comboCountPerPagePRGrid")).getValue();
            store.currentPage = 1;
            PCL.getCmp(me.buildId(me, "pagingToobarPRGrid")).doRefresh();
          },
          scope: me
        }
      }
    }, {
      xtype: "displayfield",
      fieldStyle: "font-size:13px",
      value: "张采购退货出库单"
    }];

    return result;
  },

  /**
   * @private
   */
  getQueryParamForPW() {
    const me = this;

    const result = {
      companyId: me.getCompanyId(),
      supplierId: me.getEntity().get("supplierId"),
      ref: me.editQueryRef.getValue(),
    };

    return result;
  },

  /**
   * @private
   */
  getQueryParamForPR() {
    const me = this;

    const result = {
      companyId: me.getCompanyId(),
      supplierId: me.getEntity().get("supplierId"),
      ref: me.editQueryRef.getValue(),
    };

    return result;
  },

  /**
   * @private
   */
  _onQuery() {
    const me = this;

    me.getPWDetailGrid().getStore().removeAll();
    me.getPRDetailGrid().getStore().removeAll();

    PCL.getCmp(me.buildId(me, "pagingToobarPWGrid")).doRefresh();
    PCL.getCmp(me.buildId(me, "pagingToobarPRGrid")).doRefresh();
  },

  /**
   * @private
   */
  _onClearQuery() {
    const me = this;

    me.editQueryRef.setValue(null);

    me._onQuery.apply(me);
  },

  /**
   * @private
   */
  _onPWMainGridSelect() {
    const me = this;

    const item = me.getPWMainGrid().getSelectionModel().getSelection();
    if (item == null || item.length != 1) {
      return;
    }
    const bill = item[0];

    const grid = me.getPWDetailGrid();
    const el = grid.getEl();
    el?.mask(PSI.Const.LOADING);
    me.ajax({
      url: me.URL("SLN0001/Vat/pwBillDetailList"),
      params: {
        pwBillId: bill.get("id")
      },
      callback(options, success, response) {
        const store = grid.getStore();

        store.removeAll();

        if (success) {
          const data = me.decodeJSON(response.responseText);
          store.add(data);
        }

        el?.unmask();
      }
    });
  },

  /**
   * @private
   */
  _onPRMainGridSelect() {
    const me = this;
    let grid = me.getPRMainGrid();
    const item = grid.getSelectionModel().getSelection();
    if (item == null || item.length != 1) {
      return;
    }

    const bill = item[0];

    grid = me.getPRDetailGrid();
    const el = grid.getEl();
    el?.mask(PSI.Const.LOADING);
    me.ajax({
      url: me.URL("SLN0001/Vat/prBillDetailList"),
      params: {
        id: bill.get("id")
      },
      callback(options, success, response) {
        const store = grid.getStore();

        store.removeAll();

        if (success) {
          const data = me.decodeJSON(response.responseText);
          store.add(data);
        }

        el?.unmask();
      }
    });
  },
});
